package com.dht.xiao.jianye.command.base.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author :      fangbingran
 * @aescription : todo(这里用一句话描述这个类的作用)
 * @date :        2019/06/06  13:53
 */
public class BaseLog {
    private static boolean isShowLog;

    private static SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS", Locale.CHINA);

    public static boolean isIsShowLog() {
        return isShowLog;
    }

    public static void setIsShowLog(boolean isShowLog) {
        BaseLog.isShowLog = isShowLog;
    }

    public static void print(String message) {
        if (isShowLog) {
            String source = null;
            try {
                StackTraceElement st = Thread.currentThread().getStackTrace()[2];
                source = "[" + st.getFileName() + "] - " + st.getMethodName() + "(" + st.getLineNumber() + ")";
            } catch (Exception var3) {
            }

            System.out.println(fm.format(new Date()) + " - " + source + ":" + message);
        }

    }

}
